import { Component, OnInit } from '@angular/core';
import { HeroService } from '../hero.service';
import { Hero } from '../hero';

@Component({
    selector: 'app-dashboard',
    templateUrl: './dashboard.component.html',
    styleUrls: ['./dashboard.component.css']
})
export class DashboardComponent implements OnInit {
    topNumber = 5;
    topHeroes: Hero[];

    constructor(private heroService: HeroService) { }

    ngOnInit() {
        this.heroService
            .getHeoresAsync()
            .subscribe(t => {
                this.topHeroes = t.slice(0, this.topNumber);
            });
    }



}
